package edu.mse.camel.client.core.events.model;

import java.io.Serializable;

import edu.mse.camel.client.core.idcache.ModelID;
import edu.mse.camel.client.events.AbstractEvent;
import edu.mse.camel.client.events.EventIDs;

/**
 * @author darpan
 *
 */
public class ModelUpdateEvent extends AbstractEvent implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6042790234333424540L;
	
	private byte []  byteArray;
	
	private int featureID;
	
	/**
	 * This is used only when the new value is NOT an EObject
	 */
	private Object newValue;
	
	/**
	 * This means that when we are setting a value or adding a value,
	 * the element already exists in the model. So just look up that element
	 * and add it. Don't create a new element.
	 */
	private boolean elementExists;
	
	/**
	 * This is the model id of the element that has changed.
	 * The notifier of the emf {@link org.eclipse.emf.common.notify.Notification}
	 */
	private ModelID affectedElementModelID;
	
	/**
	 * This is the id of the semantic model bridge from a diagram to the UML model.
	 */
	private ModelID semanticBridgeModelID;
	
	/**
	 * This is the id of the element if {@link isElementExists()} return true.
	 */
	private ModelID existingElementModelID;
	
	/**
	 * This is id for the new element. The model event handler should use this id
	 * to cache the new element.
	 */
	private ModelID newElementModelID;
	
	public enum EVENT_TYPE {ADD, SET, REMOVE, UNSET};
	public enum KIND {UML, DI2};
	
	private KIND kind;
	private EVENT_TYPE type;
	
	
	public ModelID getAffectedElementModelID() {
		return affectedElementModelID;
	}

	public void setAffectedElementModelID(ModelID affectedElementModelID) {
		this.affectedElementModelID = affectedElementModelID;
	}

	public ModelUpdateEvent(ModelID affectedElementModelID, KIND kind, EVENT_TYPE type) {
		this.affectedElementModelID = affectedElementModelID;
		this.kind = kind;
		this.type = type;
	}
	
	@Override
	public String getEventID() {
		return EventIDs.MODEL_UPDATE_EVENT;
	}

	public KIND getKind() {
		return kind;
	}
	
	public EVENT_TYPE getType() {
		return type;
	}

	public int getFeatureID() {
		return featureID;
	}

	public void setFeatureID(int featureID) {
		this.featureID = featureID;
	}

	public Object getNewValue() {
		return newValue;
	}

	public void setNewValue(Object newValue) {
		this.newValue = newValue;
	}

	public ModelID getElementModelID() {
		return newElementModelID;
	}

	public void setElementModelID(ModelID newElementModelID) {
		this.newElementModelID = newElementModelID;
	}
	
	public ModelID getSemanticBridgeModelID() {
		return semanticBridgeModelID;
	}

	public void setSemanticBridgeModelID(ModelID semanticBridgeModelID) {
		this.semanticBridgeModelID = semanticBridgeModelID;
	}

	public byte[] getByteArray() {
		return byteArray;
	}

	public void setByteArray(byte[] byteArray) {
		this.byteArray = byteArray;
	}

	public ModelID getExistingElementModelID() {
		return existingElementModelID;
	}

	public void setExistingElementModelID(ModelID existingElementModelID) {
		this.existingElementModelID = existingElementModelID;
	}

	public boolean isElementExists() {
		return elementExists;
	}

	public void setElementExists(boolean elementExists) {
		this.elementExists = elementExists;
	}

}
